﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Portal.Xml.Utility;

namespace Portal.Cms.Model
{
    public class ImageLevelCls
    {
        public string ImageLevelId;
        public string ImageLevelName;
        public int SortIndex = 0;
    }

    public class ImageLevelParser
    {
        public static ImageLevelCls CreateInstance()
        {
            //tao 1 class trang....
            ImageLevelCls oImageLevelCls = new ImageLevelCls();
            return oImageLevelCls;
        }

        public static ImageLevelCls ParseFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            ImageLevelCls oImageLevelCls = ParseFromDataRow(ds.Tables[0].Rows[0]);
            return oImageLevelCls;
        }


        public static ImageLevelCls ParseFromDataRow(DataRow dr)
        {
            ImageLevelCls oImageLevelCls = new ImageLevelCls();
            oImageLevelCls.ImageLevelId = XmlUtility.GetString(dr, "ImageLevelId", true);
            oImageLevelCls.ImageLevelName = XmlUtility.GetString(dr, "ImageLevelName", true);
            oImageLevelCls.SortIndex = XmlUtility.GetInt(dr, "SortIndex", true);
            return oImageLevelCls;
        }

        public static ImageLevelCls[] ParseFromDataTable(DataTable dtTable)
        {
            ImageLevelCls[] ImageLevels = new ImageLevelCls[dtTable.Rows.Count];
            for (int iIndex = 0; iIndex < dtTable.Rows.Count; iIndex++)
            {
                ImageLevels[iIndex] = ParseFromDataRow(dtTable.Rows[iIndex]);
            }

            return ImageLevels;
        }




        public static ImageLevelCls[] ParseMultiRecordFromXml(string XmlData)
        {
            DataSet ds = XmlUtility.GetDataSetFromXml(XmlData);
            if (ds.Tables.Count == 0)
            {
                return new ImageLevelCls[0];
            }
            ImageLevelCls[] ImageLevels = new ImageLevelCls[ds.Tables[0].Rows.Count];
            for (int iIndex = 0; iIndex < ds.Tables[0].Rows.Count; iIndex++)
            {
                ImageLevels[iIndex] = ParseFromDataRow(ds.Tables[0].Rows[iIndex]);
            }
            return ImageLevels;
        }
    }
}
